package com.bblocks.common.anti_reptile.demo.userId;

import com.bblocks.common.anti_reptile.service.TokenService;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>Project: bb-anti-reptile - MyTokenService</p>
 * <p>描述：提取用户id</p>
 *
 * @Author Zhao [125043150@qq.com]
 * @Date 2024/4/2 12:02
 * @Version 1.0
 * @since 8
 */
@Slf4j
@Component
public class MyTokenService implements TokenService {

    @Override
    public String token2UserId(@NonNull HttpServletRequest request,@NonNull String token) {
        String userId = (String)request.getAttribute("UserId");
        log.info("token:{} 换到 userId:{}",token,userId);
        return userId;
    }
}
